In the push data provision model, you write an independently running code that gathers the data from the underlying system and stores (pushes) it into the data variables. The OPC Wizard then simply uses this data whenever an OPC Read (or optionally subscription update) is made.
OPC Wizard retrieves the data (for OPC Reads and data subscriptions) from the ReadAttributeData Property of the data variable. The task of your code is to store the data into this property, using the UpdateReadAttributeData Method. When and how it is done is up to you, and depends highly on the specifics of the OPC server you are developing. In many cases, it can be based on some kind of periodic timer. In other scenarios, it may be triggered by the underlying system or connected device.
When the push data provision model is used, it cannot be guaranteed that the data the OPC client receives is "up to date", i.e. collected at the time when the OPC Read (or subscription update) was made. This is because there is effectively a "cache" in the form of the ReadAttributeData Property in the data variable between the underlying system and the OPC server, and the requests are fulfilled from the cache and not by actually reading from the underlying system at that moment. The push data provision model can therefore be only used in applications where this behavior does not pose a problem.
Conversely, the advantage of the push data provision model is that OPC Reads are fulfilled very quickly, as the code that retrieves the data from the underlying system cannot "block" the OPC server.
The following picture illustrates how push data provision model works.
For performance reasons, consider setting the PropagateRead Property of the data variable to false in this model. Since there is no handling of the Read Event or overriding of the OnRead Method in the push data provision model, Read request propagation is unnecessary.
When using the push data provision model, in general, you are responsible for providing the initial contents of the ReadAttributeData Property. Make sure you have a reasonable contents even before your code first gets a chance to push the "real" data to the data variable. WIthout further configuration, the ReadAttributeData Property contains empty data - meaning that the status code is "Good", but there is no timestamp, and the value itself is null. This may not be what you want - especially with non-nullable data types where null is not even a valid value for the data type of your variable; a conversion error occurs in such case, see OPC Wizard Error Model. You always need to specify initial data that make sense for your server or application.
Many extension methods for Data Variable Configuration already initialize the ReadAttributeData Property at least to the default value for the given data type. This assures that the initial value is valid for that data type, but it still may not be the "right" value for your server. Some data variable configuration extension methods (such as the ReadWriteValue Method) allow you (and force you to) specify the initial data (or just the value) directly as an argument in the method call.
The OPC Wizard also retrieves the data from the ReadAttributeData Property of the data variable for the purpose of updating the data subscriptions. If your underlying system supports different rates of data retrieval, you may want to adjust the retrieval rate based on the sampling rate of the data subscriptions. The OPC Wizard maintains the current sampling interval, computed as the shortest of the sampling intervals of current data subscriptions, in the SamplingInterval Property of the data variable, and your code can take it from there. Also, when the value of this property changes, the SamplingIntervalChanged Event is raised, and your code can react to it accordingly.
The following example illustrates this approach.
The data collection that your code performs may need to be started and stopped together with the OPC server. To achieve this, you can tie it to the Starting Event and Stopped Event of the EasyUAServer object. The following example illustrates this approach.